import { AxiosInstance, AxiosRequestConfig } from 'axios'
import { getHeaderInfo } from '../transfer-util'

export function interceptorHeader(http: AxiosInstance): void {
  http.interceptors.request.use((config: AxiosRequestConfig) => {
    const headerInfo = getHeaderInfo()
    for (const headerKey in headerInfo) {
      config.headers[headerKey] = headerInfo[headerKey]
    }

    return config
  })
}
